import 'dart:io';

import 'package:lcapp/api/request/api_client.dart';
import 'package:lcapp/api/request/response_data.dart';

class LoginAPI {

  //获取手机号验证码
  static Future<ResponseData> getPhoneCode(String phone) async {
    ResponseData responseData = await ApiClient.post("/api/user/send/phone",data: {"phone":phone},);
    return ResponseData.createFrom(responseData, responseData.data);
  }


  //手机号验证码登录
  static Future<ResponseData> login(String phone,String code) async {
    ResponseData responseData = await ApiClient.post("/api/user/phonelogin",data: {"phone":phone,"code":code});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> loginOut() async {
    ResponseData responseData = await ApiClient.post("/api/user/logout");
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> cancleAccount() async {
    ResponseData responseData = await ApiClient.post("/api/user/cancel");
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> loginOutState() async {
    ResponseData responseData = await ApiClient.post("/api/user/logoutstate");
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> loginOnState() async {
    ResponseData responseData = await ApiClient.post("/api/user/loginstate");
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> yysLogin(String token) async {
    ResponseData responseData = await ApiClient.post("/api/user/getphone",data: {
      'type':Platform.isIOS?'2':'1',
      'token':token
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

}